﻿@{
    Layout = null;
    string dataDictionaryHeadId= ViewData["dataDictionaryHeadId"].ToString();
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>新增字典项</title>
    <link href="~/Content/Scripts/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet"/>

    <style>
        body {
            overflow-x: hidden;
        }

        .table {
            width: 90%;
            margin: 0 auto;
            margin-top: 10px;
            margin-bottom: 10px;
            text-align: center;
        }

        .leftTd {
            width: 30%;
            font-weight: bold;
        }

        .rightTd {
            width: 70%;
        }

        textarea {
            resize: none;
        }
    </style>
    <!--引入脚本解决兼容性(hack技术，必须放入head中)-->
    <!--[if lt IE 9]>
        <script src="~/Content/Scripts/html5_css3/html5shiv.min.js"></script>
        <script src="~/Content/Scripts/html5_css3/respond.min.js"></script>
        <script src="~/Content/Scripts/PIE-2.0beta1/PIE_IE678.js"></script>
    <![endif]-->
</head>
<body>
    <form id="form1" method="post">
        <input type="hidden" name="DataDictionaryHeadId" value="@dataDictionaryHeadId"/>
        <table class="table table-bordered table-hover table-condensed">
            <tr>
                <td class="leftTd">文本</td>
                <td class="rightTd">
                    <input type="text" id="text" name="Text" class="form-control" placeholder="文本"/>
                </td>
            </tr>
            <tr>
                <td class="leftTd">值</td>
                <td class="rightTd">
                    <input type="text" id="value" name="Value" class="form-control" placeholder="值" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">描述</td>
                <td class="rightTd">
                    <textarea rows="3" id="description" name="Description" class="form-control" placeholder="描述"></textarea>
                </td>
            </tr>
            <tr>
                <td class="leftTd">排序号</td>
                <td class="rightTd">
                    <input type="text" id="sort" name="Sort" class="form-control" placeholder="排序号" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button id="submitBtn" type="submit" class="btn btn-success" style="margin-right: 20px;">添加</button>
                    <button type="reset" class="btn btn-danger" style="margin-left: 20px;">重置</button>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
<script src="~/Content/Scripts/jquery-2.0.3.min.js"></script>
<script src="~/Content/Scripts/layer/2.1/layer.js"></script>

<script src="~/Content/Scripts/TxyJs.js"></script>
<script>
    var iframeIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引

    $(function () {
        $("#submitBtn").click(function () {
            var item = this;
            if ($("#text").val().trim() == "" || $("#value").val().trim() == "") {
                layer.msg("请填写必要信息", { icon: 2, time: 2000 });
            }
            else {
                $(item).attr("disabled", "disabled");
                $.ajax({
                    url: "/DataDictionary/Manager/AddItemSubmit",
                    type: "post",
                    data: $("#form1").serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.Pass) {
                            parent.table1.ajax.reload();
                            parent.layer.msg(data.Msg, { icon: 1, time: 2000 });
                            parent.layer.close(iframeIndex);
                        }
                        else {
                            layer.msg(data.Msg, { icon: 2, time: 2000 });
                            $(item).removeAttr("disabled");
                        }
                    },
                    error: function (msg) {
                        layer.msg(msg.status, { icon: 2, time: 2000 });
                    }
                });
            }

            return false;
        });
    });

</script>